package com.whfc.uni.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whfc.common.exception.BizException;
import com.whfc.common.result.PageData;
import com.whfc.common.util.PageUtil;
import com.whfc.uni.dao.CarWashDataDao;
import com.whfc.uni.entity.CarWashData;
import com.whfc.uni.entity.CarWashDevice;
import com.whfc.uni.service.CarWashDataService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;

@DubboService(interfaceClass = CarWashDataService.class, version = "1.0.0")
public class CarWashDataServiceImpl implements CarWashDataService {

    @Autowired
    private CarWashDataDao carWashDataDao;

    @Override
    public void add(CarWashData carWashData) throws BizException {
        carWashDataDao.insertSelective(carWashData);
    }

    @Override
    public PageData<CarWashData> listPage(Integer pageNum, Integer pageSize, Integer deviceId, Date startTime, Date endTime) {
        PageHelper.startPage(pageNum, pageSize);
        List<CarWashData> list = carWashDataDao.selectList(deviceId,startTime,endTime);
        PageHelper.clearPage();
        return PageUtil.pageData(PageInfo.of(list));
    }

    @Override
    public List<CarWashData> list(Integer deviceId, Date startTime, Date endTime) {
        return carWashDataDao.selectList(deviceId,startTime,endTime);
    }
}
